cmake_minimum_required(VERSION 3.10)
project(security_tunnels)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(DEFINED ENV{VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "D:/vcpkg_test_ssl_libevent/vcpkg/scripts/buildsystems/vcpkg.cmake")
else()
    message(FATAL_ERROR "Please set VCPKG_ROOT environment variable to vcpkg root directory")
endif()

file(GLOB ACTION_SRC ./*.h)

find_package(libevent REQUIRED)
find_package(spdlog CONFIG REQUIRED)
add_executable(security_tunnels_server "main_server.cpp" ${ACTION_SRC})
target_link_libraries(security_tunnels_server PRIVATE libevent::core libevent::extra libevent::openssl spdlog::spdlog)
add_executable(security_tunnels_client "main_client.cpp" ${ACTION_SRC})
target_link_libraries(security_tunnels_client PRIVATE libevent::core libevent::extra libevent::openssl spdlog::spdlog)

file(COPY 
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client_cert.pem
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client_priv.pem
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/client_pub.pem
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server_cert.pem
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server_priv.pem
     ${CMAKE_CURRENT_SOURCE_DIR}/certificate/server_pub.pem
     DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
